/*************************************************************************
	> File Name: P1003.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-06 11:12:42
 ************************************************************************/
#include <iostream>
using namespace std;

#define MAX_N 10000

struct Node {
    int x, y, g, k;
} arr[MAX_N + 5];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i].x >> arr[i].y >> arr[i].g >> arr[i].k;
    }
    int x, y;
    cin >> x >> y;
    int ans = -1;
    for (int i = 1; i <= n; i++) {
        int dx = arr[i].x + arr[i].g;
        int dy = arr[i].y + arr[i].k;
        if (x >= arr[i].x && x <= dx && y >= arr[i].y && y <= dy) {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}
